监听器动作接口(ListenerAction)
当关联的 状态机监听器(State Machine Listener) 被触发时执行的动作。
更多信息见:Listener Action Scripts
方法(Methods)
init
监听器动作创建或附加时调用一次。
type MyListenerAction = {}
-- Called once when the script initializes.
function init(self: MyListenerAction, context: Context): boolean
return true
end
function perform(self: MyListenerAction, pointerEvent: PointerEvent) end
return function(): ListenerAction<MyListenerAction>
return {
init = init,
perform = perform,
}
end
perform
关联监听器触发时调用。 包含 指针事件(PointerEvent) 参数。
type MyListenerAction = {}
function init(self: MyListenerAction, context: Context): boolean
return true
end
-- Add your transition logic here.
-- `evaluate` is fired every frame while the transition is active.
-- Returning false prevents a transition, true allows a transition.
function perform(self: MyListenerAction, pointerEvent: PointerEvent)
return true
end
-- Return a factory function that Rive uses to build the Listener Action instance.
return function(): ListenerAction<MyListenerAction>
return {
init = init,
perform = perform,
}
end